package com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.page.ConventPage;
import java.util.List;
import com.xjrsoft.common.utils.DataTransUtil;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.dto.TWaterCostRecordsDayDto;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.dto.SaveTWaterCostRecordsDayFormDataDto;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.enums.MonthEnum;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.vo.TWaterCostRecordsDayVo;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.vo.TWaterCostRecordsDayListVo;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.dto.TWaterCostRecordsDayListDto;
import com.xjrsoft.core.secure.utils.SecureUtil;
import com.xjrsoft.core.tool.utils.FlowableUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.entity.TWaterCostRecordsDay;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.vo.TWaterCostRecordsDayVo;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.service.ITWaterCostRecordsDayService;

/**
 *  控制器
 *
 * @author dongxinhang
 * @since 2023-09-05
 */
@RestController
@AllArgsConstructor
@RequestMapping("/t_water_cost_records_day")
@Api(value = "每日水费记录", tags = "每日水费记录接口")
public class TWaterCostRecordsDayController {


	private final ITWaterCostRecordsDayService tWaterCostRecordsDayService;

	/**
	 * 自定义分页 
	 */
	@GetMapping
	@ApiOperation(value = "分页", notes = "传入tWaterCostRecordsDay")
		public Response<PageOutput<TWaterCostRecordsDayListVo>> getPageList(TWaterCostRecordsDayListDto listDto) {
		String month = MonthEnum.getCodeByValue(listDto.getMonth());
		if(StringUtils.isNotBlank(month)){
			listDto.setMonth(month);
		}
		IPage<TWaterCostRecordsDay> page = tWaterCostRecordsDayService.getPageList(listDto);
		List<TWaterCostRecordsDayListVo> records = BeanUtil.copyList(page.getRecords(), TWaterCostRecordsDayListVo.class);
			// 转换列表数据
		DataTransUtil.transListShowData(records);
			// 工作流数据处理
		FlowableUtil.systemFormList(records, SecureUtil.getModuleId());
		return Response.ok(ConventPage.getPageOutput(page.getTotal(), records));
	}


}
